using System.Windows.Controls;

namespace FrontDisplay
{
    internal class MoveDownAnimation : IAnimation
    {
        public void Initialize(Control control)
        {
            control.SetValue(Canvas.TopProperty, -control.Height);
        }

        public bool NextStep(Control oldControl, Control newControl)
        {
            double top = (double)newControl.GetValue(Canvas.TopProperty);

            top += newControl.Height * Animation.AnimationStep;
            if (top >= 0)
            {
                top = 0;
            }

            oldControl.SetValue(Canvas.TopProperty, top + newControl.Height);
            newControl.SetValue(Canvas.TopProperty, top);

            return (top < 0);
        }
    }
}